# 查找虚拟环境
if [ ! -d "venv" ]
then
  # Termux不使用root、安装python与pyinstaller依赖
  if [ "$OSTYPE" = "linux-android" ]
  then
    apt install python binutils ldd wget -y
  else
    sudo apt install python-is-python3 python3-pip python3-venv -y
  fi
  # 创建虚拟环境
  python -m venv venv
fi
source venv/bin/activate

# Termux需要补全部分python库
if [ "$OSTYPE" = "linux-android" ]
then
  echo -e "\033[32m[INFO] 开始补全python依赖库...\033[0m"
  if [ ! -d "termux-lib" ]
  then
    mkdir termux-lib && cd termux-lib || exit
    wget https://gitee.com/dlcn/dlscq/releases/download/ws1.9.51/termux-lib.tar.gz
    tar -xvf ./*.tar.gz && rm -r ./*.tar.gz
  else
    cd termux-lib || exit
  fi
  pip install ./*.whl -i "https://pypi.tuna.tsinghua.edu.cn/simple" && cd ..
  echo -e "\033[32m[INFO] 补全python依赖库完成！\033[0m"
fi

# 运行构建脚本
cd scripts || exit
python build.py